package cn.itcast.bos.service.base.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import cn.itcast.bos.dao.base.StandardRepository;
import cn.itcast.bos.domain.base.Standard;
import cn.itcast.bos.service.base.StandardService;
@Service
@Transactional
public class StandardServiceImpl implements StandardService{
	private static final Integer DEFAULT_ROWS = 10;
	@Autowired
	private StandardRepository standardRpository;

	@Override
	public void save(Standard s) {
		standardRpository.save(s);
	}


	@Override
	public Page<Standard> findAll(Integer page, Integer rows) {
		
		if (page==null || page<0) {
			page=0;
		}
		if (rows==null || rows<=0)  {
			rows= DEFAULT_ROWS;
		}
		PageRequest pageable = new PageRequest(page, rows);
		return standardRpository.findAll(pageable);
	}


	@Override
	public List<Standard> findAll() {
		return standardRpository.findAll();
	}	

}
